package com.dlcb.csd.controller;

import com.dlcb.csd.dto.ActionResult;
import com.dlcb.csd.po.City;
import com.dlcb.csd.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author:薛亮亮
 * @Date 2020/12/24 0:32
 * @Discription:
 */
@RestController
public class CityController {
    @Autowired
    private CityService cityService;
    @RequestMapping(value = "getCities",method = RequestMethod.GET)
    public ActionResult findCitiesByPid(int pid) {
//        ArrayList<City> cities = new ArrayList<>();
//        cities.add(new City(1,"上海",0));
//        cities.add(new City(2,"广州",0));
//        cities.add(new City(3,"深圳",0));
        List<City> cities = cityService.findCitiesByPid(pid);

        ActionResult result = new ActionResult(200,cities,null);
        return result;
    }
}
